package pers.qianyu.utils;

import cn.hutool.crypto.*;
import cn.hutool.crypto.symmetric.*;
import pers.qianyu.constants.*;

import javax.crypto.*;

public class SecurityUtil {
    /**
     * 对要存入数据库的密码进行加密
     *
     * @param password 需要加密的密码
     * @return 加密结果
     */
    public static String encryptPassword(String password) {
        SecretKey key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue(), CommConstants.AES_KEY.getBytes());
        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
        return aes.encryptHex(password);
    }
}
